<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.8.3.js" type="text/javascript"></script>
</head>
<body>
<form name="frm" method="post">
    <table width="298" border="0" align="center">
        <tr>
            <td colspan="2" align="center">简易计算器</td>
        </tr>
        <tr>
            <td width="76" align="center">第一个数</td>
            <td width="206"><input type="text" name="num1" id="num1"></td>
        </tr>
        <tr>
            <td align="center">第二个数</td>
            <td><input type="text" name="num2" id="num2"></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="button" value="+" onclick="submitForm('jia')">
                <input type="button" value="-" onclick="submitForm('jian')">
                <input type="button" value="*" onclick="submitForm('cheng')">
                <input type="button" value="/" onclick="submitForm('chu')"></td>
        </tr>
        <tr>
            <td align="center">结果</td>
            <td><input type="text" name="result" id="result" readonly></td>
        </tr>
    </table>
</form>
</body>
<script>
    function submitForm(m){

            $.ajax({
                url:m,
                type:"POST",
                data:{
                    num1:$("#num1").val(),
                    num2:$("#num2").val()
                },
                success:function (data) {
                    if (data!="error")
                    $("#result").val(data);
                    else
                        alert("除数不能为0")
                }
            })

    };
</script>
</html>